#include <iostream>
#include <vector>
#include "../matrix_lib/matrix_multiply.h"
#include "../matrix_dll/matrix_add.h"
#include "../3part/matrix_sub/matrix_sub.h" // 添加矩阵减法头文件
#include "../3part/matrix_sub_double/matrix_sub_double.h"

int main() {
    std::vector<std::vector<int>> A = {{1, 2}, {3, 4}};
    std::vector<std::vector<int>> B = {{5, 6}, {7, 8}};

    auto resultMultiply = matrixMultiply(A, B);
    auto resultAdd = matrixAdd(A, B);

    std::cout << "Matrix Multiply Result:" << std::endl;
    for (const auto& row : resultMultiply) {
        for (int val : row) {
            std::cout << val << " ";
        }
        std::cout << std::endl;
    }

    std::cout << "Matrix Add Result:" << std::endl;
    for (const auto& row : resultAdd) {
        for (int val : row) {
            std::cout << val << " ";
        }
        std::cout << std::endl;
    }


    // 准备矩阵减法所需的数组
    int rows = A.size();
    int cols = A[0].size();
    double* A_arr = new double[rows * cols];
    double* B_arr = new double[rows * cols];
    double* C_arr = new double[rows * cols];

    for (int i = 0; i < rows; ++i) {
        for (int j = 0; j < cols; ++j) {
            A_arr[i * cols + j] = A[i][j];
            B_arr[i * cols + j] = B[i][j];
        }
    }

    // 调用矩阵减法函数
    matrix_subtract(A_arr, B_arr, C_arr, rows, cols);

    std::cout << "Matrix Subtract Result:" << std::endl;
    for (int i = 0; i < rows; ++i) {
        for (int j = 0; j < cols; ++j) {
            std::cout << C_arr[i * cols + j] << " ";
        }
        std::cout << std::endl;
    }

    // 释放动态分配的内存
    delete[] A_arr;
    delete[] B_arr;
    delete[] C_arr;

    std::vector<std::vector<double>> A_ = {{1.1, 2.2}, {3.3, 4.4}};
    std::vector<std::vector<double>> B_ = {{0.5, 0.6}, {0.7, 0.8}};

    auto result = matrixDoubleSubtract(A_, B_);

    std::cout << "Matrix Double Subtract Result:" << std::endl;
    for (const auto& row : result) {
        for (double val : row) {
            std::cout << val << " ";
        }
        std::cout << std::endl;
    }

    return 0;
}
